$(document).ready(function(){ 
	$("#customer-message").click(function() { 
		var message_form = "";
			message_form = "<div id='customer-message-form'><iframe id='iframe-message' frameborder='0' style='width: 379px; height: 370px;' src='customer_message.php' hspace='0' scrolling='no'></iframe></div>";
			$('"'+message_form+'"').appendTo("body");
			$("<div id='overdiv'></div>").appendTo('body');	
	});
	
$("#customer-message-form input[name='submit']").click(function() {
		$("#form1").validate({
			rules: {
				c_name: {required: true},
				c_email: {email:true},
				c_mobile: {required: true},
				c_content: {required: true}
			},
		messages: {
				c_name: {required: '请填写您的姓名'},
				c_email: {email:'您的邮箱格式不正确'},
				c_mobile: {required: '请填写您的电话'},
				c_content: {required: '请填咨询内容'}
			},
			success:function(label) {
				label.html(' ').addClass('right');
			},
			submitHandler:function() { 
				$.ajax({ 
					type:"POST",
					url:"customer_message.php",
					data:"act=add_message&"+$("form").serialize(),
					success:function(data) { 
						if(data == 1) { 
							alert('感谢您的留言，我们将尽快与您取得联系！');
							self.parent.remove_customer_message();
						}
					}
				});
			}
		});
	});

});

function remove_customer_message()
{
	$("#customer-message-form").remove();
	$("#overdiv").remove();
	
}
